package com.bltec.emergency.mapper;

import com.bltec.emergency.model.Org;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
@Mapper
public interface OrgMapper {
    //插入一条Org记录
    @Insert("insert into org (operate,create_by,create_time,enable) " +
            "values(#{operate},#{createBy},#{createTime},#{enable})")
    boolean insert(Org org);

    //通过id设置一条记录为不可用
    @Update("update org set enable=0 where id=#{id}")
    boolean setDisableById(Long id);

    //通过id更新一条记录
    @Update("update org set operate=#{operate}," +
            "update_by=#{updateBy},update_time=#{updateTime} where id=#{id}")
    boolean updateOrgById(Org org);

    //查找符合id字段的记录
    @Select("select id,operate,create_by,create_time,update_by,update_time,enable" +
            " from org where id =#{id} and enable=1")
    Org getOrgById(Long id);

    //查找所有记录
    @Select("select id,operate,create_by,create_time,update_by,update_time,enable" +
            " from org where enable=1")
    List<Org> selectAll();
}